package kitrobot.com.bed.Service;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;

import java.io.InputStream;

import kitrobot.com.bed.StreamTools;

public class GetactbedService {
    public static String GetactbedByClientPost(String id,String token){
    try{
        HttpClient client=new DefaultHttpClient();
        String path="http://47.106.217.3:8360/app/camera/userbed?user_id="+id+"&search=";
        HttpPost httpPost=new HttpPost(path);
        httpPost.addHeader("Authorization",token);
        HttpResponse response=client.execute(httpPost);
        int code=response.getStatusLine().getStatusCode();
        if(code==200){
            InputStream is=response.getEntity().getContent();
            String text= StreamTools.readInputStream(is);
            return text;
        }
        else{
            return null;
        }
    }catch (Exception e){
        e.printStackTrace();
        return null;
    }
    }
}
